package com.easwift.qsp.das.xgy;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @Description: TODO
 * @author: huameng
 * @date: 2020年07月29日 9:11
 */
public class Client01 {
    public static void main(String[] args) throws IOException, InterruptedException {
        Socket client = new Socket("localhost", 8090);
        //2.获取流对象
        OutputStream outputStream = client.getOutputStream();

        //3.写入数据
        //for (int i=0;i<3;i++){
                                      //0x10,0x27,(byte)0xd7,(byte)0xef,0x03,0x00,0x00,0x11,0x00,0x00,0x08,0x00,(byte)0xfb,(byte)0xdd,0x00,0x00,0x00,0x00,0x00,(byte)0x80,(byte)0xfa,0x41,(byte)0xc3,0x73
             //byte[] bytes = new byte[] {0x10,0x27,(byte)0xd7,(byte)0xef,0x03,0x00,0x00,0x11,0x00,0x00,0x08,0x00,(byte)0xfb,(byte)0xdd,0x00,0x00,0x00,0x00,0x00,(byte)0x80,(byte)0xfa,0x41,(byte)0xc3,0x73};
            byte[] bytes = new byte[]{(byte)0xAA,0x55,0x00,0x01,(byte)0xFF,(byte)0x0A};
            outputStream.write(bytes);
           // System.out.println(i);
            Thread.sleep(3000);


        //}

        InputStream inputStream = client.getInputStream();
        //读取数据
        bytes = new byte[inputStream.available()];
        int len =inputStream.read(bytes, 0, inputStream.available());
        String msg = new String(bytes,0,len);
        System.out.println(msg);
        //4.关闭资源
        inputStream.close();
        outputStream.close();
        client.close();
    }
}
